home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / tjgold.zip / INSTALL.004 / FGUSER04.TXT < prev    next >
Text File  |  1995-05-29  |  49KB  |  1,155 lines

  1.                          Screen & Window Management
  2.  
  3.      "The possession of gold has ruined fewer men than the lack of it."
  4.                                          Thomas Bailey Aldrich, 1903
  5.  
  6. Introduction
  7.  
  8.           To put it bluntly, Turbo Pascal's writeln just isn't powerful
  9.      enough for today's sophisticated applications. That's why Gold
  10.      includes GOLDFAST and GOLDWIN. These units provide a powerful set
  11.      of screen and window management routines, including the following:
  12.  
  13.           A family of flexible screen writing procedures making it easy
  14.      to write at a specific location, write right-justified, write text
  15.      automatically centered between two coordinates, etc. Routines to
  16.      draw boxes and lines in a variety of shapes and sizes. The line
  17.      drawing functions can automatically join-up with other lines
  18.      already on display. 25, 43 and 50 line displays are supported.
  19.      Virtual screens which can be created, written to and then moved to
  20.      the visible screen for viewing. Multiple overlapping windows which
  21.      can be partially dragged off screen, tiled, zoomed and stretched.
  22.      Gold can write to partially or fully obscure Windows as well as the
  23.      underlying background. All or part of the screen can be saved and
  24.      restored with a variety of special effects. Routines to read the
  25.      text or attribute directly from a screen or window. Functions to
  26.      change the cursor shape and position. A set of boilerplate windows
  27.      to prompt the user to select actions such as OK or Cancel, Yes or
  28.      No, Live or Die, etc.
  29.  
  30.           TTT 5 Users  -- the windows management functions have been
  31.      totally re-written for Gold. The old-style MkWin and RmWin
  32.      procedures are still supported, but they don't offer any new
  33.      functionality and are primarily offered for backward compatibility.
  34.      To really leverage the power of Gold, you should change over to the
  35.      new Winxxx procedures.
  36.  
  37. Understanding the Active Target
  38.  
  39.           If you don't have any windows or virtual screens, life is
  40.      easy; every time you call one of the screen writing procedures
  41.      (such as WriteAT) the text is written to the screen for all to see.
  42.      No problem. However, if you have windows displayed or virtual
  43.      screens created, Gold has to know where the text should be written.
  44.      Remember, you can write to any window, virtual screen, or the
  45.      visible screen. For example, on a desktop application, you might
  46.      want to write some help text in window 1, display a list in window
  47.      2, and perhaps write the current time to the background. Rather
  48.      than force you to specify the target item with every procedure
  49.      call, Gold uses the notion of active target. That is, at any one
  50.      time either the visible screen, a virtual screen, or a window will
  51.      have the active target, and Gold will direct all screen writing
  52.      activity to that target. If you write some text which doesn't
  53.      appear, check the active target -- you might be writing to a
  54.      virtual screen or an obscured window.
  55.  
  56.      The following procedures support target management:
  57.  
  58.      ActivateWindow(Win:word);
  59.  
  60.           When you create a window, a window number or handle is
  61.      returned. This procedure sets the target to the specified window.
  62.      If the specified window does not exist, this procedure will be
  63.      ignored.
  64.  
  65.      ActivateTopWindow;
  66.  
  67.           Makes the top-most window the target. If there are no windows,
  68.      this procedure will be ignored.
  69.  
  70.      ActivateVirtualScreen(Page:word);
  71.  
  72.           Sets the target to the specified virtual screen. If the
  73.      virtual screen does not exist, this procedure will be ignored.
  74.  
  75.      ActivateVisibleScreen;
  76.  
  77.           Sets the target to be the main screen. Gold will ignore all
  78.      active windows and will write directly to the display. If there are
  79.      windows displayed, you should use the next function.
  80.  
  81.      ActivateBackground;
  82.  
  83.      Use this function when windows are displayed and you want to write
  84.      text behind the windows, i.e. to the background. If no windows are
  85.      on display, this procedure is ignored.
  86.  
  87. General Purpose String Writing
  88.  
  89. The Write Procedures
  90.  
  91.           The following GOLDFAST functions will help you to quickly and
  92.      easily write wherever you want:
  93.  
  94.      WritePlain(X,Y:byte; Str:string);
  95.      WriteAT(X,Y,FB:byte; Str:string);
  96.      WriteCol(Col,Row:byte; Str:string);
  97.      WriteClick(X,Y,FB:byte;Str:string);
  98.      WriteCenter(Y,FB:byte;Str:string);
  99.      WriteMiddle(X,FB:byte;Str:string);
  100.      WriteBetween(X1,X2,Y,FB:byte;Str:string);
  101.      WriteRight(X,Y,FB:byte;Str:string);
  102.      WriteVert(X,Y,FB:byte;Str:string);
  103.  
  104.           The procedure names are self-explanatory, but you can refer to
  105.      the Reference Manual or the on-line help for a full description of
  106.      each procedure. Note that Gold does not move the cursor during
  107.      screen writes.
  108.  
  109.           If you specify a color attribute (FB) of UseTint (defined in
  110.      GOLDATTR) with any of the screen writing procedures Gold will use
  111.      the existing display attribute, i.e. written text will assume the
  112.      color of the underlying screen or window.
  113.  
  114.           TTT 5 Users  -- all functions which accept a color use a
  115.      combined color attribute, rather than separate foreground and
  116.      background attributes. Refer to the section Specifying Display
  117.      Colors in Chapter 3 for more information.
  118.  
  119. Writing ~Hi~
  120.  
  121.           In many applications you will want to write part of a string
  122.      in one color, and the remainder of the string in another color. For
  123.      example, when displaying the text "Are you sure you want to format
  124.      the network server?", you might want the words format and network
  125.      server to be in a color which makes them stand out clearly. One way
  126.      to achieve this would be to write the text using several WriteAt
  127.      statements, with a different attribute for each statement. A
  128.      slicker way is to use Gold's WriteHi functions.
  129.  
  130.      WriteHi(X,Y,HiFB,FB:byte;Str:string);
  131.      WriteHiCenter(Y,HiFB,FB:byte;Str:string);
  132.  
  133.           By embedding tilde characters ( ~ ) in the string, you can
  134.      identify which portions of the string are to be written in each
  135.      attribute. All characters up to the first tilde are written in the
  136.      FB attribute, the text following the first tilde is written in the
  137.      HiFB attribute. Thereafter, the attribute switches every time the
  138.      tilde is encountered. The tilde characters are not displayed. To
  139.      write the server format warning (described earlier) you might use
  140.      the following statement:
  141.  
  142.      WriteHi(10,13,LightgrayOnBlue,WhiteOnBlue,
  143.               'Are you sure you want to ~format~ the ~network server?');
  144.  
  145.           The concept of embedding tilde characters in strings is
  146.      supported throughout Gold. For example, if you add an item to a
  147.      pull down menu you can highlight a character by enclosing it within
  148.      tildes, e.g. '~W~indow'. If you want to write a string with the
  149.      first capital letter in a different color, use WriteCap as follows:
  150.  
  151.      WriteCap(X,Y,FBCap,FB:byte;Str:string);
  152.  
  153.           Run the demo DEMFS1 to see a variety of the screen writing
  154.      functions in action.
  155.  
  156. Erasing Text and Changing Display Colors
  157.  
  158.      The following four procedures can be used to clear all or part of
  159.      the text:
  160.  
  161.      Clear(FB:byte; C:Char);
  162.  
  163.           Clears the entire screen or window and fills the area with the
  164.      specified character using the specified color.
  165.  
  166.      PartClear(X1,Y1,X2,Y2:byte; FB:byte; C:char);
  167.  
  168.           Similar to Clear, but only clears a specified region of the
  169.      screen or window.
  170.  
  171.      ClearLine(Y,FB:integer);
  172.  
  173.           Clears an entire line, i.e. fills the entire line with spaces,
  174.      using the specified attribute.
  175.  
  176.      ClearText(X1,Y1,X2,Y2,FB:byte);
  177.  
  178.           Similar to Clearline, but a rectangular section of the screen
  179.      or window is cleared.
  180.  
  181. Writing Non-String Information
  182.  
  183.           One of the great strengths of Turbo Pascal's writeln is its
  184.      ability to accept any number of variables of many different types.
  185.      Unfortunately, the compiler does not allow third-party developers
  186.      to create custom procedures with similar flexibility! There is no
  187.      (practical) way around the fact that Gold's screen writing
  188.      procedures only support strings. However, if you need to write
  189.      other types, you can use the string conversion functions in GOLDSTR
  190.      to cast different types to a string. For example, if you want to
  191.      write an integer variable to a string you could use the IntToStr
  192.      function as follows:
  193.  
  194.      WritePlain(1,1,IntToStr(ClientsAge));
  195.  
  196.           Although you may only pass one string argument to Gold's
  197.      screen writing procedures, you can use Turbo Pascal's string
  198.      concatenation operators to build a single string argument from
  199.      multiple string components. For example, you could display
  200.      someone's age with the following concatenated string:
  201.  
  202.      WritePlain(1,1,'Your age is '+IntToStr(ClientsAge));
  203.  
  204.           By using string casting functions and concatenation you can
  205.      gain eighty percent of writeln's flexibility and take advantage of
  206.      Gold's more powerful string writing procedures. One final thought.
  207.      If you frequently write non-string types, you might consider
  208.      writing your own procedure which is passed the non-string type and
  209.      which, in turn, calls Gold's procedure. For example, the following
  210.      procedure could be used to write any integer type:
  211.  
  212.           procedure WriteNumAt(X,Y,Attr: byte; Val:longint);
  213.           {}
  214.           begin
  215.             WriteAT(X,Y,Attr,IntToStr(Val));
  216.           end; { WriteNumAt }
  217.  
  218.           You might be wondering why we didn't include a whole family of
  219.      procedures in Gold to accommodate all the varied types that you
  220.      might need. We decided that 750 procedures was enough already.
  221.      Write your own!
  222.  
  223. Box and Line Drawing
  224.  
  225.           To draw a box on the screen or window, simply call one of the
  226.      following procedures:
  227.  
  228.      Box(X1,Y1,X2,Y2,FB,style:byte);
  229.  
  230.           Draws a rectangular box (using the ASCII box drawing
  231.      characters) at the specified coordinates in the specified
  232.      attribute. The style byte is described below. Note that the
  233.      interior of the box is not written -- whatever was on the screen
  234.      will remain visible.
  235.  
  236.      FBox(X1,Y1,X2,Y2,FB,style:byte);
  237.  
  238.           Like Box, but the interior of the box is filled.
  239.  
  240.      GrowFBox(X1,Y1,X2,Y2,FB,style:byte);
  241.  
  242.           Like FBox, but the box grows on the screen with a cutesy
  243.      exploding effect.
  244.  
  245.      Box3D(X1,Y1,X2,Y2:byte;TLFB,BRFB,Style:byte);
  246.  
  247.           Like FBox, but the upper left and lower right sides are
  248.      displayed with different attributes, giving a chiseled or 3-D
  249.      effect. (Hey, its not bad for DOS.) The style attribute may have a
  250.      value in the range 0 to 9. The box styles correspond with the
  251.      window styles used throughout Gold. The appearance of the box is
  252.      dependent upon the active character set, i.e. the box styles differ
  253.      when custom characters are in use. The following table describes
  254.      the supported box styles.
  255.  
  256.           Style  Standard Chars               Custom Chars
  257.  
  258.           0      No box (spaces)              No box (spaces)
  259.           1      Single-line                  Single-line
  260.           2      Double-line                  Single-line
  261.           3      No box (spaces)              No box (spaces)
  262.           4      Single-line                  Single edge line
  263.           5      Two-line menu layout         Two-line menu layout
  264.           6      Single line on three sides   Single line on three sides
  265.           7      Single-line chiseled out     Single-line chiseled out
  266.           8      Single-line chiseled in      Single-line chiseled in
  267.           9      Special notepad              Special notepad
  268.  
  269.  
  270.      Execute the program DEMFS2.PAS to see the supported box styles.
  271.  
  272.           To draw a single line using the following two functions, use a
  273.      Style value of 1 for single lines and 2 for double lines:
  274.  
  275.      HorizLine(X1,X2,Y,FB,Style:byte);
  276.      VertLine(X,Y1,Y2,FB,Style:byte);
  277.  
  278.           Use the smart-line drawing functions if you want to join
  279.      intersecting lines. They will automatically draw box corners, and T
  280.      junctions to join lines together. Cool.
  281.  
  282.      SmartVertLine(X,Y1,Y2,FB,Style:byte);
  283.      SmartHorizLine(X1,X2,Y,FB,Style:byte);
  284.  
  285.           Execute the demo file DEMFS3.PAS to see the smart-line
  286.      functions in action.
  287.  
  288. Reading the Display
  289.  
  290.           This section has nothing to do with optometry. If you want to
  291.      literally pull characters or attributes from a specific location on
  292.      the screen or window, you can use the following functions:
  293.  
  294.      ReadChar(X,Y:byte):char;
  295.  
  296.           Returns the character located at position (X,Y) of the target
  297.      screen or window.
  298.  
  299.      ReadAttr(X,Y:byte):byte;
  300.  
  301.           Returns the attribute (or color) at position (X,Y) of the
  302.      target screen or window.
  303.  
  304.      ReadWord(X,Y:byte;var Attr:byte; var Ch: char);
  305.  
  306.           Combines the above two functions into a single procedure call.
  307.  
  308. Customizing Scroll Bar Appearance
  309.  
  310.           Gold uses scroll bars in windows, lists, forms, etc. If you
  311.      don't like the default characters used to create the scroll bars
  312.      (shame on you), you can call the following procedure to instruct
  313.      Gold to use your preferred characters:
  314.  
  315.      SetScrollChars(U,D,L,R,E,B:char);
  316.  
  317.           Defines which characters will be used to draw horizontal and
  318.      vertical scroll bars. See the Reference Guide for further details.
  319.  
  320.           If you want to set the characters back to the (superior) Gold
  321.      defaults, simply call the procedure SetScrollDefaults.
  322.  
  323.           Call procedures WriteHScrollBar and WriteVScrollBar to
  324.      experiment with the scroll bar appearance. See the demo DEMFS4.PAS.
  325.  
  326. Automatic Line Wrapping
  327.  
  328.           GOLDFAST defines a global variable LineWrap which is used by
  329.      the screen and window writing code to control whether Gold
  330.      automatically wraps long strings to the next line. By default, line
  331.      wrapping is turned off. If you want enable line wrapping, simply
  332.      set LineWrap to true as follows:
  333.  
  334.           LineWrap := true;
  335.  
  336. Understanding Window Coordinates
  337.  
  338.           Normally, Gold uses global screen coordinates (which match the
  339.      screen dimensions). For example, the (X,Y) coordinates (5,3)
  340.      identify a location five character positions from the left side of
  341.      the display and three rows down from the top of the display. Gold
  342.      also supports local or window coordinates. When a local window is
  343.      set, all screen writing coordinates become relative to the local
  344.      window. The following routines provide coordinate support:
  345.  
  346.      SetWindow(X1,Y1,X2,Y2: byte);
  347.      ResetWindow;
  348.      SetWinIgnore(On:Boolean);
  349.      GetSetWinIgnore(On:Boolean):boolean;
  350.  
  351.           Use the procedure SetWindow to limit screen writing within the
  352.      specified coordinates. To remove the local window coordinates call
  353.      ResetWindow -- this sets the screen writing back to the global
  354.      coordinate system.
  355.  
  356.           Even though local window coordinates are set, you can instruct
  357.      Gold to ignore them (or not) using the SetWinIgnore function.
  358.      Alternatively, call GetSetWinIgnore if you want to record the
  359.      ignore state, before temporarily setting it. Having written the
  360.      appropriate data, set the coordinate state to its previous setting.
  361.      You might use this function, for example, in a hooked procedure
  362.      which displays a clock at the top right of the display, as follows:
  363.  
  364.           procedure DisplayTime;
  365.           var IgnoreState: boolean;
  366.           begin
  367.              IgnoreState := GetSetWinIgnore(true);
  368.              WriteAT(70,1,0,Time);
  369.              SetWinIgnore(IgnoreState);
  370.           end; { DisplayTime }
  371.  
  372.           The principles of active window coordinates apply to screens,
  373.      virtual screens and windows.
  374.  
  375.           The demo program DEMFS5.PAS illustrates how to manipulate the
  376.      window coordinate settings.
  377.  
  378. Managing Screens
  379.  
  380. Move Data Around the Screen
  381.  
  382.           The following three procedures manipulate data already visible
  383.      on a screen:
  384.  
  385.      CopyScreenBlock(X1,Y1,X2,Y2,X,Y:byte);
  386.  
  387.           Copies text and attributes from one part of the screen to
  388.      another. The source and target areas can overlap. The procedure is
  389.      passed the upper left and lower right coordinates of the area to
  390.      copy and the upper left coordinates of the target area.
  391.  
  392.      MoveScreenBlock(X1,Y1,X2,Y2,X,Y:byte);
  393.  
  394.           This procedure is similar to CopyScreenBlock except the
  395.      original source area is erased.
  396.  
  397.      Scroll(Way:gDirection;X1,Y1,X2,Y2:byte);
  398.  
  399.           Scrolls text in a rectangular region of the screen. The data
  400.      can be scrolled in any of the following four directions: Up, Down,
  401.      Left, Right. One row or column of text is removed, blank characters
  402.      are inserted in their place.
  403.  
  404. Using Virtual Screens
  405.  
  406.           When is a screen not a screen?  When it's a virtual screen. A
  407.      virtual screen emulates the characteristics of the standard video
  408.      memory, but is located on the heap. Virtual screens are used to
  409.      save copies of the visible screen, as well as to prepare screens
  410.      which can be pushed onto the visible screen in a flash (or with a
  411.      sliding special effect).
  412.  
  413.           By default Gold supports five virtual screens. If (for some
  414.      bizarre reason) you need more virtual screens, change the
  415.      MaxVirtualScreens setting in GOLDFAST to a higher value.
  416.  
  417. Creating Virtual Screens
  418.  
  419.           To create a virtual screen simply call CreateScreen as
  420.      follows:
  421.  
  422.      CreateScreen(Page,W,D,FB:byte);
  423.  
  424.           The page number is a value in the range 1 to MaxVirtualScreens
  425.      (see note above). If that page is being used by another virtual
  426.      screen, the screen will be overwritten. W and D represent the
  427.      screen width and depth, respectively. A virtual screen can be as
  428.      large as 255 characters wide by 255 rows deep. The last parameter,
  429.      FB, is the default attribute of the newly created screen.
  430.  
  431.           Before writing to a virtual screen you should set the target
  432.      focus using the ActivateVirtualScreen procedure (discussed
  433.      earlier).
  434.  
  435. Saving the Visible Screen
  436.  
  437.           By calling SaveScreen you can create a virtual screen (with
  438.      the same dimensions as the display) and automatically copy the
  439.      visible screen contents to the virtual screen along with the cursor
  440.      position and size. Use this function when you want to save the
  441.      screen in its entirety to restore it later.
  442.  
  443.      SaveScreen(Page:byte);
  444.  
  445.      Saves the current screen (on the heap) for a subsequent restore.
  446.      The only parameter passed is the page or screen number. If a screen
  447.      has already been created with the same screen number, the old
  448.      screen will be overwritten.
  449.  
  450.           When a virtual screen is created using CreateScreen or
  451.      SaveScreen, memory must be allocated on the heap. Always check the
  452.      LastFastError function to make sure the screen creation was
  453.      successful. If the procedure fails due to a lack of memory, there
  454.      are two probable causes.
  455.  
  456.           1 -- There really isn't enough memory.
  457.           2 -- The maximum heap available has been restricted by the $M
  458.                compiler directive (or the IDE equivalent).
  459.  
  460. Restoring Screens
  461.  
  462.           The user can only see the contents of a virtual screen when it
  463.      is restored to the visible screen. To quickly restore a screen call
  464.      the RestoreScreen procedure and identify the page or screen number
  465.      of the page to be restored. The virtual screen is not affected by a
  466.      restore; you can restore the same screen many times.
  467.  
  468.           If you only want to restore part of a virtual screen, use the
  469.      following function:
  470.  
  471.      PartRestoreScreen(Page,X1,Y1,X2,Y2,X,Y:byte);
  472.  
  473.           Restores part of a virtual screen. The procedure is passed the
  474.      screen number, the upper-left and lower-right coordinates of the
  475.      area of the screen to be restored and the target coordinates for
  476.      the top left corner of the area, i.e. part of a saved screen can be
  477.      restored to a different location on the visible screen.
  478.  
  479.           For a little more pizzazz you can use a slide.i..n...g effect
  480.      when you restore the screen. A little bit of flash goes a long way.
  481.      The two slide functions (listed below) accept an additional
  482.      argument of type gDirection, which is declared in GOLDFAST as
  483.      follows:
  484.  
  485.           gDirection = (Up,Down,Left,Right,Vert,Horiz);
  486.  
  487.           As you might have deduced (Iowans excepted) this argument
  488.      controls the direction used to slide the screen onto the display.
  489.  
  490.      SlideRestoreScreen(Page:byte;Way:gDirection);
  491.      PartSlideRestoreScreen(Page:byte;Way:gDirection;X1,Y1,X2,Y2:byte);
  492.  
  493. Disposing of Screens
  494.  
  495.           Virtual screens consume memory (about 4000 bytes per 80 by 25
  496.      screen). When you no longer need a virtual screen, you should
  497.      dispose of it using the DisposeScreen function, as follows:
  498.  
  499.      DisposeScreen(Page:byte);
  500.  
  501.           Dispose of the memory used to store a virtual screen. If the
  502.      specified screen doesn't exist, the procedure is ignored.
  503.  
  504. Using Condensed Screens
  505.  
  506.           Systems equipped with EGA or VGA displays can support the
  507.      display of 43 or 50 lines of text. GOLDFAST includes the following
  508.      two procedures to switch between condensed and standard modes.
  509.  
  510.      SetCondensed;
  511.  
  512.           Changes the display to 43 or 50 line mode.
  513.  
  514.      Set25;
  515.  
  516.           Sets the display mode to a standard 25 lines.
  517.  
  518.           The Gold variable HardVars.Depth is set to reflect the number
  519.      of display lines.
  520.  
  521.           The mouse cursor will not be aware that the size of the screen
  522.      has been altered. Having switched display modes you should call the
  523.      mouse function MouseConfine (discussed in the next chapter) to
  524.      allow the mouse to navigate the entire visible screen (and no
  525.      more).
  526.  
  527.           Run the demo DEMFS6.PAS to see how to set display modes, and
  528.      how to adjust the mouse.
  529.  
  530. Using Prefabricated Windows
  531.  
  532.           Most applications use a set of "standard windows" to interact
  533.      with the user, e.g. message windows with some text and an OK
  534.      button.
  535.  
  536.           Gold provides a set of prompt procedures and functions which
  537.      make it easy to display text in a window. In each case, the
  538.      procedure is passed a title and a message, and Gold computes the
  539.      appropriate window size and position based on the length and
  540.      content of the message text.
  541.  
  542.           For example, the following statement would instruct Gold to
  543.      display a window with the title "Yowsa" and the message "What's
  544.      happening babe?":
  545.  
  546.           PromptOK('Yowsa','What''s happening babe?');
  547.  
  548.           The user would be presented with the message window containing
  549.      the text and a single OK button. Gold automatically calculates the
  550.      window dimensions based on the input.
  551.  
  552.           The window style (i.e. box border) can be modified by setting
  553.      the value of the variable WinVars.PromptStyle to a value in the
  554.      range 1 to 9. The default is style 7.
  555.  
  556.           Gold provides the following prompt procedures and functions:
  557.  
  558.      PromptOK(Tit,Msg:string);
  559.  
  560.           Displays a message in a window with an OK button.
  561.  
  562.      PromptOKCancel(Tit,Msg:string): byte;
  563.  
  564.           Displays the title and message with OK and Cancel buttons. A 1
  565.      is returned if OK is selected, and a 2 if Cancel is selected.
  566.  
  567.      PromptYesNo(Tit,Msg:string): byte;
  568.  
  569.           Like PromptOKCancel but the buttons say Yes and No.
  570.  
  571.      PromptCustom(Tit,Msg:string; But1,But2,But3:StrButton;
  572.                   HK1,HK2,HK3, Default:word; WaitTime:longint): byte;
  573.  
  574.           Displays a custom prompt window with up to three custom
  575.      buttons. As well as the title and the message, the function is
  576.      passed the text of three buttons (null if the button is not needed)
  577.      along with the hotkey for each button and the default. The final
  578.      parameter is the wait time in milliseconds -- specify zero if you
  579.      want to force the user to make a choice, otherwise the function
  580.      will return a zero if the user has not pressed a button before the
  581.      wait period has expired.
  582.  
  583.           In addition to the above prompt functions which accept the
  584.      message as a single string, there are a corresponding set of
  585.      functions which accept string linked lists (discussed in Chapter
  586.      13) and are called PromptOKStrSLL, PromptOKCancelStrSLL,
  587.      PromptYesNoStrLL, and PromptCustomStrLL. These functions allow you
  588.      to display messages longer than 255 characters.
  589.  
  590.           Both the message text and the buttons supported embed "~"
  591.      characters to allow two display colors to be used. Also, you can
  592.      embed a split vertical bar character "|"  in the message string to
  593.      force a line break, i.e. all text following the character will be
  594.      written to the next line. One final tip: any line commencing with
  595.      the "^" character will be automatically centered in the window. All
  596.      these special characters are automatically stripped from the
  597.      message before it is displayed.
  598.  
  599.           The button strings used in the standard (non-custom) prompt
  600.      windows are defined as variables in GOLDWIN as follows:
  601.  
  602.           OKButStr: strButton = '  ~O~K  ';
  603.           OKHotKey = 280;          { Alt+O }
  604.           CancelButStr: strButton = '~C~ancel';
  605.           CancelHotKey = 302;      { Alt+C }
  606.           YesButStr: strButton = '   ~Y~es   ';
  607.           YesHotKey = 277;         {Alt-Y}
  608.           NoButStr: strButton = '   ~N~o   ';
  609.           NoHotKey = 305;          {Alt-N}
  610.  
  611.           Both the text and the hotkeys can be changed for international
  612.      applications.
  613.  
  614.           If you need to display a message longer than 255 characters,
  615.      the message can be passed in the form of a string linked list
  616.      (discussed in Chapter 13) using the following functions:
  617.  
  618.      PromptOKStrLL(Tit:string;StrLL:StringLL);
  619.      PromptOKCancelStrLL(Tit:string;StrLL:StringLL): byte;
  620.      PromptYesNoStrLL(Tit:string;StrLL:StringLL): byte;
  621.      PromptCustomStrLL(Tit:string; StrLL:StringLL;  But1,But2,
  622.                        But3:StrButton;  HK1,HK2,HK3,Default:word;
  623.                        WaitTime:longint): byte;
  624.  
  625.           Other Gold units provide specialized windows such as forms,
  626.      lists, calendars, calculators, file browsers and text editors.
  627.  
  628. Customizing Display Colors
  629.  
  630.           The colors used by the prompt windows are defined in GOLDTINT.
  631.      The following table lists the member name along with the area
  632.      affected:
  633.  
  634.           Tint Element        Description
  635.  
  636.           PromptBorder1       The color of the border line.
  637.           PromptBorder2       The secondary color of the border line
  638.                               when the style variable
  639.                               WinVars.PromptStyle is set to 7 or 8.
  640.           PromptTitle         The color of the title.
  641.           PromptBody          The color of the window body.
  642.           PromptBodyHi        The window of the highlighted text in the
  643.                               window body, i.e. the text after the '~'.
  644.           PromptButtonNorm    Standard color of the button when the
  645.                               button doesn't have focus.
  646.           PromptButtonNormHot Hi color of the button when the button
  647.                               doesn't have focus.
  648.           PromptButtonHi      Standard color of the button when the
  649.                               button has focus.
  650.           PromptButtonHiHot   Hi color of the button when the button has
  651.                               focus.
  652.  
  653.           If you want to use custom display colors, simply change the
  654.      appropriate element of the TINT color structure using the
  655.      GoldSetcolor procedure. The following code is an extract of
  656.      DEMPMT2.PAS:
  657.  
  658.           if ColorScreen then
  659.           begin
  660.              GoldSetColor(PromptBorder1,LightRedOnRed);
  661.              GoldSetColor(PromptBorder2,LightRedOnRed);
  662.              GoldSetColor(PromptTitle,WhiteOnRed);
  663.              GoldSetColor(PromptBody,LightGrayOnRed);
  664.              GoldSetColor(PromptButtonHiHot,WhiteOnMagenta);
  665.              GoldSetColor(PromptButtonHi,YellowOnMagenta);
  666.              GoldSetColor(PromptButtonNormHot,YellowOnMagenta);
  667.              GoldSetColor(PromptButtonNorm,LightgrayOnMagenta);
  668.           end;
  669.  
  670.           Run the demos DEMPMT1.PAS to DEMPMT5.PAS to see the prompt
  671.      windows in action.
  672.  
  673. Creating and Managing Custom Windows
  674.  
  675.           If the standard prompt windows (described above) don't meet
  676.      your needs, you can create your own custom windows.
  677.  
  678. Window Principles
  679.  
  680.           Gold supports an infinite number of windows (limited only by
  681.      memory). A window has very similar properties to a screen: each
  682.      window has a width, each window has a height, a window has an
  683.      active cursor position and shape, and within the window there is an
  684.      active area which can be written to. In addition to the screen-like
  685.      properties, a window has a position, a style (or border design),
  686.      and a title.
  687.  
  688.           When you want to display some information in a window, you
  689.      should take the following steps:
  690.  
  691.           Decide on the window's dimensions, initial position, and style
  692.           (discussed in the next section), then create a window
  693.           structure by calling the WinCreate function, e.g.
  694.  
  695.                WinNum := WinCreate(5,5,75,20,4);
  696.  
  697.           The value returned by WinCreate is the logical window number
  698.           (or handle) -- the first window will be window 1, etc. This
  699.           window handle must be specified in the procedures called in
  700.           steps 2 and 3. If WinCreate returns a zero, the window was not
  701.           created (probably due to a lack of memory).
  702.  
  703.      Note:  Gold has not actually displayed the window at this stage;
  704.      behind the scenes a window structure has been created in Gold's
  705.      internal window list.
  706.  
  707.           Customize the window characteristics (such as the colors,
  708.           title, etc.) using the WinSet... functions, e.g.
  709.  
  710.                WinSetTitle(1,' The Title ');
  711.  
  712.           Display the window by calling WinDisplay, e.g.
  713.  
  714.                WinDisplay(1);
  715.  
  716.           Get input from the user and check to see whether it is a
  717.           window-specific keystroke/mouse action by calling the boolean
  718.           function IsWinKey. If the function returns true, pass the
  719.           keystroke data to the procedure WinProcessKey for processing,
  720.           e.g.
  721.  
  722.                GetInput;
  723.                if IsWinKey(LastKey,LastX,LastY) then
  724.                   WinProcessKey(LastKey,LastX,LastY);
  725.  
  726.           Refresh the window contents (having written new data to it) by
  727.           calling WinDrawTop or WinDrawAll.
  728.  
  729.           The following code is an extract from DEMWIN1.PAS which
  730.           illustrates how to create, display and write to a window:
  731.  
  732.                WinHandle := WinCreate(5,5,75,20,1);
  733.                WinSetType(WinHandle,WMove);
  734.                WinSetTitle(WinHandle,' My First Window ');
  735.                WinDisplay(WinHandle);
  736.                WritePlain(1,1,'This .....');
  737.                WinDrawAll;
  738.                MouseShow(true);
  739.                {now process keystrokes}
  740.                with KeyVars do
  741.                   repeat
  742.                      GetInput;
  743.                      if IsWinKey(LastKey,LastX,LastY) then
  744.                         WinProcessKey(LastKey,LastX,LastY);
  745.                   until (LastKey = 27) or (LastKey = 600);
  746.                MouseShow(false);
  747.                ResetStartupMode;
  748.  
  749.      Run the program DEMWIN1.PAS to see the code in action.
  750.  
  751.           To summarize, the window management process is: create,
  752.      customize, display, handle input, redraw.
  753.  
  754. Window Styles
  755.  
  756.           A window style controls the format of the window border, i.e.
  757.      whether it is single line, double line, etc. Gold supports nine
  758.      different window styles -- ten, if you count style 0 which is no
  759.      border.
  760.  
  761.           When a window is created (with the WinCreate function) the
  762.      last byte parameter identifies the window style, and it should be a
  763.      value in the range 0 through 9. These style numbers correspond with
  764.      the box styles discussed on page 5-6. As with box styles, window
  765.      styles are affected by the use of custom characters (refer to
  766.      Chapter 3 for more information).
  767.  
  768.           Run the demo DEMWIN2.PAS to interactively modify the window
  769.      styles and see the impact on the window border.
  770.  
  771.      The WinSet... Procedures
  772.  
  773.           After a window has been created, the properties of the windows
  774.      can be changed from the defaults by using the following procedures:
  775.  
  776.      WinSetType(Win:integer;W:WinType);
  777.  
  778.           The window type controls which of the window border icons are
  779.      active and visible. Windows can be a combination of closeable,
  780.      moveable and stretchable. The first parameter identifies which
  781.      window will have the type changed, and the second parameter
  782.      indicates the new type. WinType is defined (in GOLDWIN) with the
  783.      following members:
  784.  
  785.           WinType           Description
  786.  
  787.           WPlain            No icons.
  788.           WClose            Close icon.
  789.           WMove             Close icon and window can be dragged.
  790.           WMoveNoClose      Window can be dragged but no close icon.
  791.           WStretch          Window can be stretched, dragged and closed.
  792.  
  793.      WinSetMinSize(Win:integer;Width,Depth: byte);
  794.  
  795.           Defines the minimum size that a user can make a stretchable
  796.      window.
  797.  
  798.      WinSetScrollType(Win:integer;S:ScrollType);
  799.  
  800.           Defines whether the window has horizontal and/or vertical
  801.      scroll bars. The enumerated type ScrollType is defined in GOLDFAST
  802.      with the following members: NoScroll, HorizScroll, VertScroll,
  803.      BothScroll.
  804.  
  805.      WinSetColor(Win:integer; A:TintElement;C:byte);
  806.  
  807.           Sets the display color of a specific component (or element) of
  808.      the window, e.g. the icons, the frame, the body, etc. See the
  809.      section Window Colors (below) for further information.
  810.  
  811.      WinSetShowNum(Win:integer;On:boolean);
  812.  
  813.           Controls whether or not the window number is displayed on the
  814.      top right of the window border.
  815.  
  816.      WinSetTitle(Win:integer;Tit:string);
  817.  
  818.           Sets the window title. Set to null to erase a title.
  819.  
  820.      WinSetPosition(Win:integer;NewX,NewY:shortint);
  821.  
  822.           Use this procedure to change the position of the top left
  823.      corner of the window.
  824.  
  825.      WinSetStretchProc(Win:integer;S:StretchProc);
  826.  
  827.           During a user actioned window stretch (i.e. when the user is
  828.      dragging the lower right window corner) Gold can call a stretch
  829.      procedure to provide a way for the application to dynamically
  830.      update the window during a stretch operation. Call this procedure
  831.      to identify the name of the procedure which will be called as the
  832.      window is stretched. Note that the procedure must be declared far
  833.      with the following format:
  834.  
  835.           procedure MyProc(X1,Y1,X2,Y2:byte);
  836.  
  837. Window Shadows
  838.  
  839.           GOLDFAST includes the global variables ShadowType and
  840.      ShadowAttr which control the position and color of window shadows.
  841.      The shadow attribute may be any value in the range 0 to 255, and
  842.      has a default value of 7 (lightgray on black). The following table
  843.      identifies the impact of different ShadowType values:
  844.  
  845.           Value       Shadow Position
  846.  
  847.           0           Shadows drawn up and to the left.
  848.           1           Shadows drawn up and to the right.
  849.           2           Shadows drawn down and to the left.
  850.           3           Shadows drawn down and to the right.
  851.           4 or more   No shadow.
  852.  
  853. Window Colors
  854.  
  855.           For coloring purposes, a window is composed of several
  856.      components, each of which may be assigned a different color. The
  857.      table below lists the component together with a description.
  858.  
  859.           Component Description
  860.  
  861.           WinBorder        The standard window border.
  862.           WinBorder3DIn    The "in" bump portion of the border for
  863.                            styles 7 and 8.
  864.           WinBorder3DOut   The "out" bump portion of the border for
  865.                            styles 7 and 8.
  866.           WinTitle         The window title.
  867.           WinBody          The central part of the window (where text is
  868.                            written).
  869.           WinIcons         The close, zoom and stretch icons.
  870.           WinCaption       The color of the title bar (or caption) when
  871.                            used in styles 3 and 6 (the Windows emulation
  872.                            styles).
  873.           WinCustom        The color used to draw the Microsoft
  874.                            Windows-style close and zoom icons for window
  875.                            styles 3 and 6.
  876.           WinBorderOff     The colors used to draw windows on the
  877.                            desktop which don't have focus.
  878.  
  879.           There are two additional window colors which were not included
  880.      in the table: WinMoveHi and WinMoveBody. These members are used to
  881.      define the colors of the message displayed when a user presses
  882.      Ctrl-F5 to move a window using the cursor keys.
  883.  
  884.           The default window colors are defined in GOLDTINT; there is
  885.      one set for monochrome systems and another for color systems.
  886.  
  887.           To change the display colors for an individual window, you can
  888.      call the WinSetColor procedure (discussed earlier) identifying the
  889.      window component and the desired color, e.g.
  890.  
  891.      WinSetColor(WinNum,WinBorder,WhiteOnRed);
  892.      WinSetColor(WinNum,WinTitle,YellowOnRed);
  893.      WinSetColor(WinNum,WinBody,LightgrayOnRed);
  894.      WinSetColor(WinNum,WinIcons,LightcyanOnRed);
  895.  
  896.           However, if you want to use a different (non-default) color
  897.      scheme for all windows, change the GOLDTINT defaults prior to
  898.      creating the windows. Refer to the section Customizing Display
  899.      Colors in Chapter 3 for more information.
  900.  
  901. The Impact of Custom Characters
  902.  
  903.           Gold creates custom characters for line drawing, window icons,
  904.      etc. The standard ASCII double line characters are not available
  905.      when custom characters are active. If you have custom characters
  906.      enabled, and you request a window style which uses double-line
  907.      characters (such as style 2) Gold will automatically draw single
  908.      lines instead. You can see the effect of the custom characters on
  909.      window shapes by running DEMWIN1.PAS and toggling the Custom
  910.      Characters check box. Refer to Chapter 3 for more information on
  911.      the impact of custom characters on box and border drawing.
  912.  
  913. Processing Window Input
  914.  
  915.           There are many different user inputs which must be managed in
  916.      a custom window: clicking on the various icons, dragging the window
  917.      around the screen, stretching the window, double-clicking on the
  918.      title, etc. Fortunately, Gold can manage all these inputs and leave
  919.      you free to deal with the non-window related keystrokes and mouse
  920.      clicks.
  921.  
  922.           The intricacies of managing mouse and keyboard input are
  923.      discussed in the next Chapter, but the principles are simple. Any
  924.      single user input can be defined with three variables: the
  925.      keystroke which is of type word, and two bytes which identify the X
  926.      and Y coordinates of the mouse cursor.
  927.  
  928.           Having garnered user input you can test whether the input is a
  929.      window action by calling the function IsWinKey which is defined as
  930.      follows:
  931.  
  932.      IsWinKey(K:word;KX,KY:byte):boolean;
  933.  
  934.           The function is passed three parameters identifying the
  935.      keystroke details and returns true if the keystroke is a window
  936.      management keystroke which can be handled automatically by Gold.
  937.      If the function returns false, the keystroke is not associated with
  938.      a generic window manipulation task (such as zoom or move), and
  939.      should be handled by the application's own keyboard handler.
  940.  
  941.           If IsWinKey returns true, call the function WinProcessKey
  942.      (defined below) to have Gold process the keystroke and manipulate
  943.      the window as necessary.
  944.  
  945.      WinProcessKey(var K:word; var KX,KY:byte);
  946.  
  947.           This procedure is passed the window-related keystroke.
  948.  
  949.           Having processed the keystroke, Gold updates the passed
  950.      parameters to indicate what window activity transpired. An
  951.      application should evaluate the updated parameters and redraw the
  952.      window contents as appropriate. For example, if the window was
  953.      stretched, K will be updated with a value of  602, and the values
  954.      of X and Y are irrelevant.
  955.  
  956.           The following table identifies the values which can be
  957.      assigned to K along with those instances where X and Y also have a
  958.      meaning.
  959.  
  960.           Key    Explanation
  961.  
  962.           600    The user clicked on the close icon and the window has
  963.                  been closed.
  964.           601    The window was moved or dragged.
  965.           602    The window was zoomed or stretched, i.e. resized.
  966.           610    The user clicked on the up arrow on the vertical
  967.                  scrollbar.
  968.           611    The user clicked on the down arrow on the vertical
  969.                  scrollbar.
  970.           612    The user clicked on the left arrow on the horizontal
  971.                  scrollbar.
  972.           613    The user clicked on the right arrow on the horizontal
  973.                  scrollbar.
  974.           614    The user clicked along the length of the vertical
  975.                  scrollbar. X is updated to reflect the number of
  976.                  characters down the scrollbar where the user clicked,
  977.                  and Y identifies the length of the scrollbar in
  978.                  characters.
  979.           615    The user clicked along the length of the horizontal
  980.                  scrollbar. X is updated to reflect the number of
  981.                  characters along the scrollbar where the user clicked,
  982.                  and Y identifies the length of the scrollbar in
  983.                  characters.
  984.  
  985. The Timing of Window Updates
  986.  
  987.           The code which manages the window kernel is complex and
  988.      primarily written in assembly language. So there! However, an
  989.      understanding of the general architecture will help you to figure
  990.      out when the visible screen is updated. It may also explain some of
  991.      the odd behavior that occurs when you are tracing a program using
  992.      the debugger.
  993.  
  994.           To allow for updates to fully or partially obscured windows,
  995.      Gold maintains a window image off-screen. More often than not, an
  996.      application will write several different strings to a window at one
  997.      time. When you write to a window, the off-screen image of the
  998.      window is immediately updated, but, to avoid unnecessary screen
  999.      updates, the window image is not immediately transferred to the
  1000.      visible screen.
  1001.  
  1002.           The windows are updated on the visible screen when one of the
  1003.      following two functions is called:
  1004.  
  1005.      WinDrawAll;
  1006.  
  1007.           Forces an update of the screen background and all the windows.
  1008.      Thanks to the brilliance of the windows code, the user will not
  1009.      experience any flicker as the windows are updated.
  1010.  
  1011.      WinDrawTop;
  1012.  
  1013.           The top-most window is redrawn.
  1014.  
  1015.           If you want every window update to be automatically displayed
  1016.      on the visible screen, set the global GOLDFAST variable ShowNow to
  1017.      true.
  1018.  
  1019. Cursor Management
  1020.  
  1021.           Routines are available for hiding and displaying the cursor as
  1022.      well as changing the cursor shape from thin to half to full, or to
  1023.      any other available shape. The cursor routines function on
  1024.      monochrome and color video systems. As with screen and window
  1025.      updates, the cursor management functions are specific to the active
  1026.      window or screen.
  1027.  
  1028. Setting the Cursor Shape
  1029.  
  1030.           The following procedures can be used to set the cursor to one
  1031.      of four standard shapes:
  1032.  
  1033.      CursorOff;
  1034.  
  1035.           Makes the cursor invisible.
  1036.  
  1037.      CursorOn;
  1038.  
  1039.           Makes the cursor visible and sets it to the default DOS shape,
  1040.      i.e. a blinking line at the bottom of the character.
  1041.  
  1042.      CursorHalf;
  1043.  
  1044.           Makes the cursor a block filling the lower half of the
  1045.      character field.
  1046.  
  1047.      CursorFull;
  1048.  
  1049.           Makes the cursor a full block filling the entire character
  1050.      field.
  1051.  
  1052.           In text mode, an individual character is comprised of a number
  1053.      of scan lines. Usually the cursor is located on one or two scan
  1054.      lines near the bottom of the character. Different display systems
  1055.      use varying numbers of scan lines. For example, a monochrome
  1056.      display usually has fourteen scan lines, as does an EGA system, but
  1057.      a CGA only has 8. Use the function CharHeight to return the actual
  1058.      number of scan lines per character, before using CursorSize to set
  1059.      the cursor to a custom size.
  1060.  
  1061.      CharHeight: integer;
  1062.  
  1063.           Returns the number of scan lines per character used by the
  1064.      video display system in the current mode.
  1065.  
  1066.      CursorSize(T,B:byte);
  1067.  
  1068.           Sets the cursor to the specified top and bottom scan lines.
  1069.      The top scan line (e.g. the top bar of the letter "T") is scan line
  1070.      zero. As an example, to set the cursor to a half block filling the
  1071.      upper half of the screen (on a VGA system), call:
  1072.  
  1073.      SizeCursor(0,7);
  1074.  
  1075.      DEMFS8.PAS illustrates the cursor setting procedures.
  1076.  
  1077. Setting the Cursor Position
  1078.  
  1079.           You guessed it, to change the position of the cursor, call
  1080.      GotoXY and pass the new (X,Y) coordinates of the cursor. Gold's
  1081.      GotoXY is more sophisticated than Borland's GotoXY. For example, if
  1082.      you position the cursor in a window in a location that is
  1083.      physically off screen (because the window has been partially
  1084.      dragged screen), Gold will automatically make the cursor invisible.
  1085.  
  1086.      GotoXY(X,Y:byte);
  1087.  
  1088.           Positions the cursor (using local coordinates) relative to the
  1089.      active window or screen.
  1090.  
  1091. Getting the Cursor Details
  1092.  
  1093.           The following three routines will return information about the
  1094.      active window or screen's cursor location and size:
  1095.  
  1096.      CursorFind(var X,Y,Top,Bot:byte);
  1097.  
  1098.           Updates the passed parameters with the (X,Y) coordinates of
  1099.      the cursor, and the cursor's top and bottom scan lines.
  1100.  
  1101.      WhereX: byte;
  1102.  
  1103.           Returns the X coordinate position of the cursor.
  1104.  
  1105.      WhereY: byte;
  1106.  
  1107.           Returns the Y coordinate position of the cursor.
  1108.  
  1109.           If you want to manage the cursor using standard global screen
  1110.      coordinates (ignoring any local coordinates, windows and screens,
  1111.      etc.), you can use one of the following absolute cursor routines:
  1112.  
  1113.      AbsGotoXY(X,Y:byte);
  1114.      AbsWhereXY(var X,Y:byte);
  1115.      AbsCursorSize(T,B:byte);
  1116.  
  1117. Error Management
  1118.  
  1119.           Some of the GOLDFAST and GOLDWIN functions have the potential
  1120.      to fail. For example, CreateScreen may have insufficient memory.
  1121.      The Reference Manual identifies every procedure and function which
  1122.      may fail and set a non-zero error code. GOLDFAST and GOLDWIN
  1123.      provide the following two functions to test the success of the last
  1124.      command:
  1125.  
  1126.      LastFastError: integer;
  1127.      LastWinError: integer;
  1128.  
  1129.      Refer to Chapter 3 for more information on error management.
  1130.  
  1131. Other Neat Stuff
  1132.  
  1133.           Listed below are some additional procedures and functions
  1134.      which you may find useful:
  1135.  
  1136.      DrawShadow(X1,Y1,X2,Y2:integer);
  1137.  
  1138.           Draws a lightgray shadow down and to the right of the
  1139.      specified coordinates.
  1140.  
  1141.      Attrib(X1,Y1,X2,Y2,FB:byte);
  1142.  
  1143.           Changes the display attribute (i.e. color) of a region of the
  1144.      active screen or window. Note the text in the affected area is not
  1145.      deleted -- only the color of the text is changed. The procedure is
  1146.      passed the upper left and lower right (X,Y) coordinates together
  1147.      with the desired display attribute.
  1148.  
  1149.      ResetStartUpMode;
  1150.  
  1151.           Sets the display device to the same mode that was in effect
  1152.      when the program was executed and automatically removes any custom
  1153.      characters and replaces them with the standard ASCII character set.
  1154.  
  1155.